# -*- coding: utf-8 -*-
# author yzs
# date 2018-12-29

# Searching_2
# Description
# Find the count of numbers less than N having exactly 9 divisors
# 1<=T<=1000,1<=N<=10^12
# Input
# First Line of Input contains the number of testcases. Only Line of each testcase contains the number of members N
# in the rival gang.
# Output
# Print the desired output.
# Sample Input 1 
# 2
# 40
# 5
# Sample Output 1
# 1
# 0
# 思路，两个质数的平方积以及一个质数的八次方都可以得到九个因数的数
import math


def create_prime_list(num):
    prime = []
    for i in range(2, num):
        is_prime = False
        for j in range(2, int(math.sqrt(i)) + 1):
            if i % j == 0:
                is_prime = True
                break
        if not is_prime:
            prime.append(i)
    return prime


prime_list = create_prime_list(50000)


def count_divisors_is_nine(n):
    count = 0
    list_len = len(prime_list)
    for i, prime in enumerate(prime_list):
        if pow(prime, 8) < n:
            count += 1
        else:
            break
    num = math.sqrt(n)
    for i in range(list_len):
        if prime_list[i] > num:
            break
        for j in range(i + 1, len(prime_list)):
            if prime_list[i] * prime_list[j] < num:
                count += 1
            else:
                break
    print(count)


t = int(input().strip())
for i in range(t):
    n = int(input().strip())
    count_divisors_is_nine(n)


